package com.hanscan.persistence.entities;

import java.io.Serializable;
import javax.persistence.*;

@Entity
@Table(name = "terminals")
@Inheritance(strategy = InheritanceType.JOINED)
@SequenceGenerator(name = "terminalGen", sequenceName = "terminalGen", allocationSize =
1)
@NamedQueries(
{
    @NamedQuery(name = "getAllTerminals",
    query = "SELECT t FROM Terminal t"),
    @NamedQuery(name = "findTerminalById",
    query = "SELECT t FROM Terminal t " +
    "WHERE t.terminalId=?1"),
    @NamedQuery(name = "findTerminalByMac",
    query = "SELECT t FROM Terminal t " +
    "WHERE UPPER(t.mac)=?1"),
    @NamedQuery(name = "findTerminalByMame",
    query = "SELECT t FROM Terminal t " +
    "WHERE UPPER(t.name)=?1"),
        @NamedQuery(name = "findTerminalByCompany",
    query = "SELECT t FROM Terminal t " +
    "WHERE UPPER(t.company)=?1"),
    @NamedQuery(name = "findTerminalByMacAndCompany",
    query = "SELECT t FROM Terminal t " +
    "WHERE UPPER(t.mac)=?1 AND t.company.companyId=?2"),
    @NamedQuery(name = "findTerminalByMameAndCompany",
    query = "SELECT t FROM Terminal t " +
    "WHERE UPPER(t.name)=?1 AND t.company.companyId=?2")
})
public class Terminal implements Serializable
{
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "terminalGen")
    private Long terminalId;

    //Atributos
    @Column(nullable = false)
    private String mac;    
    private String keyEncryption;
    private String name;
    @OneToOne
    private Company company;

    public String getKeyEncryption()
    {
        return keyEncryption;
    }

    public void setKeyEncryption(String keyEncryption)
    {
        this.keyEncryption = keyEncryption;
    }

    public String getMac()
    {
        return mac;
    }

    public void setMac(String mac)
    {
        this.mac = mac;
    }

    public Long getTerminalId()
    {
        return terminalId;
    }

    public void setTerminalId(Long terminalId)
    {
        this.terminalId = terminalId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public Company getCompany()
    {
        return company;
    }

    public void setCompany(Company company)
    {
        this.company = company;
    }

}
